-- =============================================
-- Author:		Dawid Ejdeholm
-- Create date: 2017-11-27
-- Description: Stored procedures for easy use.
-- =============================================


-- Name:		employee_insert
-- Description: Adds a new employee
CREATE PROCEDURE employee_insert
    (@fname varchar(255), @lname varchar(255), @email varchar(255), @phone varchar(50), @postalcode int, @address varchar(255))
AS
BEGIN
    INSERT INTO Employee
    VALUES (@fname, @lname, @email, @phone, @postalcode, @address)
End
-- Result:	Adds person into employee
GO

-- Name:		StepsForRecipe
-- Description: Get the steps and instruction for a @recipeID.
CREATE PROCEDURE StepsForRecipe 
    (@recipeID int)
AS
BEGIN
    SELECT StepNumber, Instruction
	FROM Steps
    WHERE Steps.RecipeID = @recipeID
End


-- Name:		IngredientsForRecipes
-- Description: Get the ingredients, amount and unit for a @recipeID
CREATE PROCEDURE IngredientsForRecipes(@recipeID int)
AS
BEGIN
	SELECT Recipes.RecipeName, Ingredients.IngredientName, StepIngredient.amount, StepIngredient.unit FROM Recipes
	 JOIN StepIngredient ON Recipes.RecipeID = StepIngredient.RecipeID
	 JOIN Ingredients ON StepIngredient.IngredientID = Ingredients.IngredientID
	 WHERE Recipes.RecipeID = @recipeID
END